import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:hive_flutter/hive_flutter.dart';
import 'package:ichinesereader/controller/cache.dart';
import 'package:ichinesereader/controller/evaluation.dart';
import 'package:ichinesereader/utils/log.dart';
import 'package:ichinesereader/widgets/grids/evaluationClassReportDataGrid.dart';
import '../../themes/appTheme.dart';

class EvaluationClassReportForTeacher extends GetView<EvaluationController> {
  static const String routeName = '/teacher/evaluation/classreport';

  @override
  Widget build(BuildContext context) {
    Log.debug('build teacher evaluation class reports');
    final box = Hive.box('appconfig');
    box.put('SkillType', 'Report');
    final EvaluationController _evaluationController = Get.find();

    var classId = box.get(CacheManagerKey['currentclass'].toString());

    Future.delayed(Duration(milliseconds: 200), (() {
      if (classId != null && classId != '')
        _evaluationController.fetchEvaluationClassReportData(
            classId, _evaluationController.currentLevel.value.toString());
    }));

    return Scaffold(
      backgroundColor: Colors.transparent,
      //floatingActionButton: FloatingActionButtonsTeacherSwitchClass(),
      body: Column(
        crossAxisAlignment: CrossAxisAlignment.start,
        children: [
          Expanded(
            child: Container(
              margin: EdgeInsets.only(top: 6.0),
              decoration: BoxDecoration(
                borderRadius: BorderRadius.circular(3.0),
                color: Get.isDarkMode
                    ? AppTheme.colors.darkTheme1
                    : Colors.white.withOpacity(0.3),
              ),
              child: Container(
                color:
                    Get.isDarkMode ? AppTheme.colors.darkTheme2 : Colors.white,
                margin: EdgeInsets.all(12.0),
                child: controller.obx(
                  (data) => EvaluationClassReportDataGrid(
                      controller.studentEvaluationDetails, true),
                  onEmpty: Text('Data not available ...'.tr),
                  onLoading: Container(),
                ),
              ),
            ),
          ),
        ],
      ),
    );
  }
}
